<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>深拷贝</title>
</head>
<body>
<script src="./deepClone.js"></script>
<script>
  function Person() {
    this.name = 'Samuel';
    this.age = 26;
    this.real = true;
    this.number = NaN;
    this.addrs = [
      {id: 1, title: '浙江杭州'},
      {id: 2, title: '湖南长沙'},
    ];
    this.sym = Symbol('unique');
    this.sub = {
      name: 'little white butts',
    }
    this.reg = /fake\w+$/;
    this.func = function () {
      return 'Function';
    };
    this.birth = new Date();
    this.nMap = new Map();
    this.nMap.set('rnm', ['退钱', ['淦']]);
  }

  Person.prototype.getName = function () {
    console.log(this.name);
  }
  var a = new Person();
  a.self = a;
  console.log(a);
  var b = deepClone(a);
  console.log(b);
  a.nMap.get('rnm').push('???');
  a.nMap.get('rnm')[1].push('???');
  console.log('修改a:', a);
  console.log('修改a后的b:', b);
</script>
</body>
</html>
